from kubernetes import client, config

def get_cluster_info():
    # 加载 kubeconfig 文件，如果没有指定，则使用默认的 kubeconfig 文件
    config.load_kube_config()

    # 创建 CoreV1Api 的实例，用于与集群通信
    v1 = client.CoreV1Api()

    # 获取集群节点信息
    nodes = v1.list_node().items

    # 打印节点信息
    for node in nodes:
        print("Node Name: %s\tNode IP: %s" % (node.metadata.name, node.status.addresses[0].address))
        print(node.metadata.name)
        print(node.status.addresses[0].address)
        print(node.metadata.creation_timestamp)
        print(node.spec.pod_cidr)
        print(node.status.capacity)
        print(node.status.allocatable)
        # print(node.status.images)


if __name__ == "__main__":
    get_cluster_info()
